var crypto = require('crypto');
var cryptojs = require('crypto-js');

crypto.createHmac('sha1', app_secret).update('待加密字串').digest().toString('base64'); //base64
crypto.createHmac('sha1', app_secret).update('待加密字串').digest('hex');   //16进制

var str = 'orderId=21140600050549799429&orderStatus=TRADE_SUCCESS&payTime=2014-07-22 11:43:31';
var key = 'REzySUKRCPfyfV/jfgwTA==';
var sign = CryptoJS.HmacSHA1(str, key).toString();

